package main;

/*
 * Author: Samantha Choy
 * Date: July 29, 2014
 * File name: SimpleICS.java
 * Function: to take strings and parse into an ICS file
 * Input: None
 * Output: ICS file
 * 
 * More info about this project can be found at https://code.google.com/p/ics314-sum14-amur-cal/
 * 
 */

import java.io.*;

public class SimpleICS {
	
	public static final String icsFileName = "amurCalendar.ics";
	
	public static void main(String[] args) throws FileNotFoundException {
		System.out.println("Making ICS file...");
		SimpleICS.toICSFile("Study for exam", "20140813T100000", "20140813T130000", "Hamilton Library");
		System.out.println("DONE!");
	}//end main()
	
	public static void toICSFile(String newName, String newStartDT, String newEndDT, String newLocation) throws FileNotFoundException {
		String textOutput = "BEGIN:VCALENDAR\nPRODID:-//Google Inc//Google Calendar 70.9054//EN\nVERSION:2.0"
				+ "\nCALSCALE:GREGORIAN\nBEGIN:VEVENT";
		textOutput = textOutput + "\nDTSTART;TZID=Pacific/Honolulu:" +  newStartDT + "\nDTEND;TZID=Pacific/Honolulu:" + newEndDT 
				+ "\nLOCATION:" + newLocation + "\nSUMMARY:" + newName + "\nEND:VEVENT\nEND:VCALENDAR";
		
		PrintWriter myFile = new PrintWriter(icsFileName);
		myFile.println(textOutput);
		myFile.close();
	}//end toICSFile()
	
	public static void toICSFileSimple(String newName, String newStartDT, String newEndDT, String newLocation) throws FileNotFoundException {
		String textOutput = "BEGIN:VCALENDAR\nCALSCALE:GREGORIAN\nBEGIN:VEVENT\nDTSTART;TZID=Pacific/Honolulu:" 
				+ newStartDT + "\nDTEND;TZID=Pacific/Honolulu:" + newEndDT + "\nCLASS:PRIVATE\nLOCATION:" 
				+ newLocation + "\nSUMMARY:" + newName + "\nEND:VEVENT\nEND:VCALENDAR";
		
		PrintWriter myFile = new PrintWriter("amurSimple.ics");
		myFile.println(textOutput);
		myFile.close();
		
	}//end toICSFileSimple()

}//end SimpleICS class
